package com.twu.biblioteca.util;

import com.twu.biblioteca.exception.InvalidInputException;

import java.util.Scanner;

import static com.twu.biblioteca.util.Messages.YOU_HAVE_LOGOUT_THE_LIBRARY_SYSTEM;

public class CommonUtils {

    public static void logoutSystem() {
        System.out.println(YOU_HAVE_LOGOUT_THE_LIBRARY_SYSTEM);
        System.exit(-1);
    }

    public static String getInput() {
        Scanner scanInput = new Scanner(System.in);
        String inputStr = scanInput.nextLine();
        return inputStr;
    }

    public static int getInputId(String bookId) {
        try {
            return Integer.parseInt(bookId);
        } catch (NumberFormatException e) {
            throw new InvalidInputException();
        }
    }
}
